home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
language
/
forth_83.zoo
/
ramdisk.scr
< prev
next >
Wrap
Text File
|
1992-04-07
|
27KB
|
1 lines
HOW TO USE THE RAMDISK bp 17Aug86 Die Ramdisk ist im Prinzip ein erweiterter Buffermechanismus, der Buffer außerhalb des Forth-Systems verwaltet. Die Organi- sation ist analog, mit der Ausnahme, daß es kein Updateflag gibt, geänderte Blöcke also sofort auf die Diskette zurückge- schrieben werden. Die Benutzung ist völlig transparent, am Anfang muß nur einmal INITRAMDISK aufgerufen werden. Die Struktur der Buffer wird auf Screen 3 dargestellt. Die Ramdisk allokiert ihren Speicher mit MALLOC. \ loadscreen for more buffers bp 17Aug86 \needs 2over include double.scr Onlyforth \needs 4dup : 4dup 2over 2over ; \needs 4drop : 4drop 2drop 2drop ; \needs user' : user' ' >body c@ ; \needs d> : d> 2swap d< ; 2 $B +thru 1 +load \ patch ramdisk into system \ patch ramdisk into System bp 17Aug86 | : ((close ( fcb -- fcb ...) \ word for patch (CLOSE !! dup flushramfile [ Dos ' (close >body @ , ] ; | : (empty-buffers ( -- ...) \ word for patching EMPTY-BUFFE emptyramdisk [ ' empty-buffers >body @ , ] ; ' ramdiskr/w is r/w ' ((close Dos ' (close >body ! ' (empty-buffers ' empty-buffers >body ! save initramdisk \ Variables and Constants bp 10Aug86 2Variable ramprev 0. ramprev 2! \ points to first buffer 2Variable ramfirst 0. ramfirst 2! \ start of buffer area 2Variable ramsize 0. ramsize 2! \ length of buffer area $408 Constant b/rambuf | Code link>file ( d1 -- d2 ) .l 4 SP ) addq Label >next Next end-code | Code link>block .l 6 SP ) addq >next bra end-code | Code link>data .l 8 SP ) addq >next bra end-code \\ structure of a buffer: | link to next buffer | file | block | data .... | +0 +4 +6 +8 +1032 \ search for a buffer bp 24Aug86\ D0:blk D1:file A0:bufadr A1:Vorgaenger Label thisbuffer? 4 A0 D) D1 cmp 0= IF 6 A0 D) D0 cmp THEN rts Code rambuf? ( blk file -- dadr tf \ blk file ) 2 SP D) D0 move SP ) D1 move .l ramprev r#) A0 move .w thisbuffer? bsr 0= IF Label blockfound .l 8. # A0 adda A0 SP ) move .w true # SP -) move Next THEN BEGIN .l A0 A1 move A1 ) A0 move 0. # A0 cmpa .w 0= IF false # SP -) move Next THEN thisbuffer? bsr 0= UNTIL .l A0 ) A1 ) move ramprev r#) A0 ) move A0 ramprev r#) move .w blockfound bra end-code \ read and write buffers b28sep86we | : readrambuf ( adr daddr -- ) \ copy from daddr to adr rot >absaddr b/blk lcmove ; | : writerambuf ( adr daddr --) \ copy from adr to daddr rot >absaddr 2swap b/blk lcmove ; \ search for empty buffer bp 10Aug86 \ : takerambuf ( -- daddr ) \ get last buffer \ ramprev 2@ \ BEGIN 2dup link>file l@ 1+ ( empty buffer ? ) \ WHILE 2dup l2@ or ( last buffer ? ) \ WHILE l2@ REPEAT ; | Code takerambuf ( -- daddr ) .l ramprev r#) A0 move Label takeloop .w -1 4 A0 D) cmpi 0<> IF .l A0 ) tst 0<> IF A0 ) A0 move takeloop bra THEN THEN A0 SP -) move Next end-code \ allocate a buffer bp 24Aug86 | 2Variable (daddr \ | : markrambuf ( blk file daddr -- daddr ) \ 2dup (daddr 2! link>file l! (daddr 2@ link>block l! \ (daddr 2@ ; | Code markrambuf ( blk file daddr -- daddr ) .l SP )+ A0 move .w SP )+ 4 A0 D) move SP )+ 6 A0 D) move .l A0 SP -) move Next end-code | : makerambuf ( adr blk file -- ) \ create a buffer BEGIN rambuf? 0= WHILE 2dup takerambuf markrambuf 2drop REPEAT writerambuf ;